package com.zyh.server.config;

import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
/**
 * @Author: zyh
 * @Date: 2024-11-14-11:37
 * @Description mybatis-plus配置文件
 */
@Configuration
public class MybatisPlusConfig {

	//Interceptor 拦截器
	// MybatisPlusInterceptor 拦截器，是第3方创建的
	// 使用 @Bean注解交给Spring的IOC容器管理

	@Bean
	public MybatisPlusInterceptor mybatisPlusInterceptor() {
		//1.创建MybatisPlus拦截器对象
		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
		//2.创建分页插件(参数是数据库类型)
		PaginationInnerInterceptor paginationInnerInterceptor =
				new PaginationInnerInterceptor(DbType.MYSQL);
		//3.将分页插件添加到拦截器中
		interceptor.addInnerInterceptor(paginationInnerInterceptor);
		return interceptor;
	}

}
